class xT_AICommand_Cmd_Crouch extends xT_AICommand_Cmd;

//=============================================================================
// Variables: Movement
//=============================================================================
var private Vector                      CurrentLocation;
var private Vector                      MoveDestination;
var public bool                         bAIisStanding; //used for x-com pawns to know when pawn is moving and when is standing;
var private Vector                      TempDest; // for scripted move

//=============================================================================
// State
//=============================================================================
AUTO state Crouch
{
	function DoDuck()
	{	
		if(Pawn != None)
		{	
			if (xT_Pawn(Pawn).Position == EP_Howering) return;

			if (xT_Pawn(Pawn).Position == EP_Sitting)
			{			
				Pawn.ShouldCrouch(false);
				Pawn.GroundSpeed = Pawn.Default.GroundSpeed;
				xT_Pawn(Pawn).Position = EP_Standing;
			}
			else
			{
				if (xT_Pawn(Pawn).Position == EP_Standing)
				{
					Pawn.ShouldCrouch(true);
					Pawn.GroundSpeed = Pawn.Default.GroundSpeed/2;
					xT_Pawn(Pawn).Position = EP_Sitting;
				}
			}
		}
	}

Begin:
	//`log("xT_AICommand_Crouch executed");

Crouching:
	DoDuck();
	sleep(WorldInfo.DeltaSeconds); // Little delay while wait for crouching or standing

	PopCommand(Self);
}

//=============================================================================
// DefaultProperties
//=============================================================================
defaultproperties
{
}
